<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .login-container {
            background-color: white;
            padding: 40px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            width: 400px;
        }
        .login-title {
            text-align: center;
            margin-bottom: 30px;
            color: #333;
        }
        .form-group {
            margin-bottom: 20px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
            color: #555;
        }
        .form-group input {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        .captcha-group {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .captcha-group input {
            flex: 1;
        }
        .captcha-img {
            cursor: pointer;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        .btn {
            width: 100%;
            padding: 12px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            margin-bottom: 10px;
        }
        .btn:hover {
            background-color: #0056b3;
        }
        .btn-secondary {
            background-color: #6c757d;
        }
        .btn-secondary:hover {
            background-color: #545b62;
        }
        .register-link {
            text-align: center;
            margin-top: 20px;
        }
        .register-link a {
            color: #007bff;
            text-decoration: none;
        }
        .register-link a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <h2 class="login-title">用户登录</h2>
        <form action="login" method="post">
            <div class="form-group">
                <label for="username">用户名:</label>
                <input type="text" id="username" name="username" required>
            </div>
            
            <div class="form-group">
                <label for="password">密码:</label>
                <input type="password" id="password" name="password" required>
            </div>
            
            <div class="form-group">
                <label for="captcha">验证码:</label>
                <div class="captcha-group">
                    <input type="text" id="captcha" name="captcha" required maxlength="4">
                    <img src="captcha" alt="验证码" class="captcha-img" onclick="refreshCaptcha()" title="点击刷新验证码">
                </div>
            </div>
            
            <button type="submit" class="btn">登录</button>
            <button type="button" class="btn btn-secondary" onclick="refreshCaptcha()">刷新验证码</button>
        </form>
        
        <div class="register-link">
            <p>还没有账号？<a href="register.html">立即注册</a></p>
        </div>
    </div>

    <script>
        function refreshCaptcha() {
            var captchaImg = document.querySelector('.captcha-img');
            captchaImg.src = 'captcha?' + new Date().getTime();
        }
        
        // 页面加载时刷新验证码
        window.onload = function() {
            refreshCaptcha();
        };
    </script>
</body>
</html>
